<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加会员等级</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/css/admin.css">
    <script src="/static/layui/layui.js"></script>
</head>
</body>
<div class="layui-container" style="margin-top: 30px;">
    <form class="layui-form">
        <input type="hidden" name="id" value="{$row.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">等级名称</label>
            <div class="layui-input-block">
                <input type="text" name="grade_name" value="{$row.grade_name}" required lay-verify="required"
                       placeholder="请输入等级名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">升级条件</label>
            <div class="layui-input-block">
                <input type="number" name="full_integral_upgrade" required lay-verify="required" placeholder="请输入累计积分"
                       autocomplete="off" value="{$row.full_integral_upgrade}" class="layui-input">
                <div class="layui-form-mid layui-word-aux layui-font-red">满足条件自动升级一下级会员,为不影响认真填写积分数</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠折扣</label>
            <div class="layui-input-block">
                <input type="text" name="discount" value="{$row.discount}" required lay-verify="required"
                       placeholder="请输入折扣" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">生日赠送积分倍数</label>
            <div class="layui-input-block">
                <input type="number" name="birthday_give_integral" value="{$row.birthday_give_integral}" required 
                       placeholder="请输入倍数" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">等级描述</label>
            <div class="layui-input-block">
                <textarea name="desc" placeholder="请输入内容" class="layui-textarea">{$row.desc}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" {if $row.status==1}checked{/if} title="启用">
                <input type="radio" name="status" value="0" {if $row.status==0}checked{/if} title="禁用">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formAdd">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form'], function () {
        var $ = layui.jquery, form = layui.form;

        form.on('submit(formAdd)', function (data) {
            $.post('/store/user/grade/update', data.field, function (res) {
                if (res.code == 1) {
                    let index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.location.reload();
                }

                return layer.msg(res.msg, {icon: 2});
            });

            return false;
        });

    });
</script>
</body>
</html>